﻿<!DOCTYPE html>
<html lang="en" style="background:#fff;">
<head>
    <base href="${basePath}">
    <#include "common/top.html"/>
</head>
<body style="background:#fff;">
<form class="layui-form layui-form-pamel" name="form1" id="form1" method="post">
    <div class="layui-form-item-dept">
        <input type="hidden" name="userId" id="userId" value="${userId}"/>
        <input id="roleId" name="roleId" type="hidden">
        <ul>
            <#list sysRole as var >
            <li style="float: left;width: 55%;">
					<span>
                        <input type="checkbox" lay-skin="primary"  lay-filter="filter"
                               lay-verify="title" name="roleId1" value="${var.roleId}"
                               title="${var.roleName}" ${var.checked}>
					</span>
            </li>
        </#list>
        </ul>
    </div>
</form>
</body>
<script type="text/javascript">

    var form;
    var arr = new Array();
    layui.use(['form'], function () {
        form = layui.form;
        form.on('checkbox(filter)', function (data) {
            arr.length = 0;
            $("input:checkbox[name=roleId1]:checked").each(function(){
                arr.push($(this).val());
            });
            $("#roleId").val(arr.join(","));

        });
        form.render();
    });

    //保 存
    function save() {
        $.ajax({
            url: "${basePath}system/user/saveUserLimit",
            data: $("#form1").serialize(),
            type: "POST",
            success: function (data) {
                if (data.status == true) {
                    layer.alert(data.msg, function (index) {
                        var index1 = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index1);
                        layer.close(index);
                    });
                } else {
                    parent.layer.alert(data.msg);
                }
            }
        })
    }

</script>
</html>
